#  cmake -DCMAKE_BUILD_TYPE=Debug ../../"El Barrio es lo Primero"/.
#  cmake -DCMAKE_BUILD_TYPE=Release ../../"El Barrio es lo Primero"/.
#  cmake -DCMAKE_BUILD_TYPE=Debug -G Xcode ../../"El Barrio es lo Primero"/.
#  cmake -DCMAKE_BUILD_TYPE=Release -G Xcode ../../"El Barrio es lo Primero"/.

#  !!!!! USAR SIMPRE CON EJECUTABLES DES-OPTIMIZADOS -O0 !!!!!!
#  valgrind -v --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes ./ejecutable

SET(CMAKE_LEGACY_CYGWIN_WIN32 0)

project(EL_BARRIO_ES_LO_PRIMERO)
cmake_minimum_required( VERSION 2.6 FATAL_ERROR )

SET(TARGET "ElBarrioEsLoPrimero")
 
MESSAGE( "SCAN DE SISTEMA" )
MESSAGE( "==========================================================================" )
MESSAGE( STATUS "SISTEMA ACTUAL              : "${CMAKE_SYSTEM_NAME} )
MESSAGE( STATUS "MODO                        : "${CMAKE_BUILD_TYPE} )
MESSAGE( STATUS "CMAKE_COMPILER_IS_GNUCXX    : "${CMAKE_COMPILER_IS_GNUCXX} )
MESSAGE( STATUS "UNIX                        : "${UNIX} )
MESSAGE( STATUS "WIN32                       : "${WIN32} )
MESSAGE( STATUS "APPLE                       : "${APPLE} )
MESSAGE( STATUS "MINGW                       : "${MINGW} )
MESSAGE( STATUS "MSYS                        : "${MSYS} )
MESSAGE( STATUS "CYGWIN                      : "${CYGWIN} )
MESSAGE( STATUS "BORLAND                     : "${BORLAND} )
MESSAGE( STATUS "WATCOM                      : "${WATCOM} )
MESSAGE( "==========================================================================" )

add_executable(${TARGET} 
				actor.cpp
				argumentos.cpp  
				carg_juego.cpp 
				colisiones.cpp
				configurador.cpp 
				ElFuler.cpp
				Eventos.cpp
				Fase_Config.cpp
				Fase_DBG.cpp
				Fase_Intro.cpp 
				fx.cpp
				IA.cpp
				Imagen.cpp				
				main.cpp 
				Menu.cpp
				Musica.cpp
				SDL_FrameRate.cpp 
				Textos.cpp 
				utils.cpp	

				ElFuler.hpp
				Eventos.hpp
				Fase_Config.hpp	
				Fase_DBG.hpp
				Fase_Intro.hpp
				IA.hpp
				Imagen.hpp
				Menu.hpp
				Musica.hpp
				SDL_FrameRate.hpp
				Textos.hpp
				actor.hpp
				argumentos.hpp
				carg_juego.hpp
				cargador.hpp
				colisiones.hpp
				configurador.hpp
				fase.hpp
				fx.hpp
				main.hpp
				paths.hpp
				proyectil.hpp
				tipos_glob.hpp
				utils.hpp					
				)


IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")	
    MESSAGE( "SISTEMA: Apple OS X" )
    MESSAGE( "==========================================================================" )	
    IF(${CMAKE_BUILD_TYPE} MATCHES "Debug")
      add_definitions("-std=c++98 -DAPPLE -O0 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
    ELSE()
      add_definitions("-std=c++98 -DAPPLE -O3 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
    ENDIF()

    Find_Package ( SDL REQUIRED )
	Find_Package ( SDL_image REQUIRED ) 
	Find_Package ( SDL_ttf REQUIRED )
	Find_Package ( SDL_mixer REQUIRED )

	IF ( NOT SDL_FOUND )
		MESSAGE ( FATAL_ERROR "Librerias SDL no encontradas. Son dependencias obligatorias(SDL, Image, Mixer, TTF)" )
	ENDIF( NOT SDL_FOUND )
	target_link_libraries ( ${TARGET} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDLMIXER_LIBRARY})

ELSE()
	IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
		MESSAGE( "SISTEMA: Linux" )
		MESSAGE( "==========================================================================" )
           
		IF(${CMAKE_BUILD_TYPE} MATCHES "Debug")
			add_definitions("-std=c++98 -DLINUX -O0 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
		ELSE()
			add_definitions("-std=c++98 -DLINUX -O3 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
		ENDIF()
		Find_Package ( SDL REQUIRED )
		Find_Package ( SDL_image REQUIRED ) 
		Find_Package ( SDL_ttf REQUIRED )
		Find_Package ( SDL_mixer REQUIRED )
		IF ( NOT SDL_FOUND )
			MESSAGE ( FATAL_ERROR "Librerias SDL no encontradas. Son dependencias obligatorias(SDL, Image, Mixer, TTF)" )
		ENDIF( NOT SDL_FOUND )
		target_link_libraries ( ${TARGET} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDLMIXER_LIBRARY})              
	ELSE()
		MESSAGE( STATUS "ATENCION ALGO VA MAL !!! -> NO SE HA DETECTADO EL SISTEMA : " ${CMAKE_SYSTEM_NAME})
		MESSAGE( "==========================================================================" )
	ENDIF()
ENDIF()
